<template>
	<!-- 身份认证 -->
	<view>
		<view class="edit">
			<view class="editPass flex">
				<text>真实姓名</text>
				<input type="text" :disabled="status" placeholder="请输入真实姓名" v-model="realname"/>
			</view>
			<view class="editPass flex">
				<text>身份证号</text>
				<input type="text" :disabled="status" placeholder="请输入身份证号码" v-model="id_number"/>
			</view>
		</view>
		<view class="warn flex-c" v-if="!status">
			<text>真实姓名及身份证号作为领奖的重要凭证，填写成功后不可更改</text>
		</view>
		<view class="editBtn flex-c" v-if="!status" @click="fnVerIdcard()">
			<text>确认</text>
		</view>
	</view>
</template>

<script>
	const util = require('../../../common/util.js')
	export default {
		data() {
			return {
				realname:'',
				id_number:'',
				status:false,
				token:uni.getStorageSync('token')
			};
		},
		onLoad(option) {
			console.log(option.status)
			if(option.status == 0){
				this.status = false
			}else{
				this.status = true
			}
			this.realname = option.realname
			this.id_number = option.id_card
		},
		methods:{
			fnVerIdcard(){
				console.log(this.realname)
				console.log(this.id_number)
				if(!this.realname) return uni.showToast({
					title:'请输入真实姓名',
					icon:'none'
				})
				if(!this.id_number || !util.isIdNo(this.id_number)) return uni.showToast({
					title:'请输入正确的身份证号',
					icon:'none'
				})
				this.request({
					url: '/czb/user/userBindIdCard',
					method: 'POST',
					data: {
						'store_id': 1,
						'token':this.token,
						'realname':this.realname,
						'id_card':this.id_number,
					},
				}).then((ret) => {
					console.log(ret);
					if (ret.code == 0) { 
						uni.showToast({
							title:ret.message,
							icon:'success'
						})
						setTimeout(function(){
							uni.navigateBack()
						},1500)
					}
				})
			}
		}
		
	}
</script>

<style lang="scss" scoped>
	page{
		padding: 30rpx 0;
	}
	.edit{
		.editPass{
			height: 120rpx;
			background: #fff;
			padding: 0 20rpx;
			font-size: 28rpx;
			margin-bottom: 30rpx;
			align-items: center;
			text{
				flex: 1;
				font-size: 30rpx;
			}
			input{
				flex: 2.5;
			}
		}
	}
	.warn{
		font-size: 24rpx;
		color: #999;
		margin-top: 20rpx;
	}
	.editBtn{
		width: 710rpx;
		height: 90rpx;
		border-radius: 20rpx;
		background: linear-gradient(270deg, #F22F29, #FC6655);
		margin: 60rpx auto 20rpx;
		color: #fff;
		font-size: 30rpx;
	}
</style>
